<?php 

class TestController extends Controller {
	public function __construct(){
		$this->calledClass(get_class($this));
	}
	public function index(){
		$objTest = $this->loadModel("Test");
		//$this->set(array("list"=>$user->query()));
		//$this->set(array("list"=>$user->getAsArray(array("pos_title","pos_bycompany","pos_experience"))));
		$this->set(array("list"=>$objTest->getList($this->get("page"),$this->get("perpage")?$this->get("perpage"):20,$this->get("search"),array("emp_bussines_name"))));
		//$this->layout = "ltableemployer" ;
		$this->render("index");
	}
	/* end Menu  */

	/*
	 * select
	* insert
	* edit
	* update
	* delete
	*  */
	public function display(){
		$user = $this->loadModel("Employer");
		//$this->set(array("list"=>$user->query()));
		//$this->set(array("list"=>$user->getAsArray(array("pos_title","pos_bycompany","pos_experience"))));
		$this->set(array("list"=>$user->getList($this->get("page"),$this->get("perpage")?$this->get("perpage"):20,$this->get("search"),array("emp_bussines_name"))));
		//$this->layout = "ltableemployer" ;
		$this->render("ltableemployer");

	}
	public function addNew(){
		if(isset($_POST["btnAdd"])){
			$user = $this->loadModel("Employer");
			$dateToday = date("d-m-Y");
			$newDate = date("Y-m-d", strtotime($dateToday));
			$addJob=$user->save(array(
					"firstname"=>trim($this->get("txtFname")),
					"lastname"=>trim($this->get("txtLname")),
					"username"=>trim($this->get("txtUserId")),
					"password"=>trim($this->get("txtPassWord")),
					"email"=>trim($this->get("txtEmail")),
					"bussiness"=>trim($this->get("txtBuinessName")),
					"created"=>trim($newDate)
					));
			$this->display();
		}else{
			//$this->layout = "lnewemployer" ;
			$this->render("lnewemployer");
		}
	}
	public function edit(){
		$user = $this->loadModel("Test");
		$user->findObject(array("id"=>$this->get("pid")));
		$this->set(array("arrFind"=>$user->findObject(array("id"=>$this->get("pid")))));
		
		/* 
		$this->set(array("Vmode"=>$user->getAsArray(array("pos_mode"))));
		$this->set(array("Vjoblevel"=>$user->getAsObject(array("pos_joblevel"))));
		$this->set(array("Vjobtime"=>$user->getAsObject(array("pos_jobtime"))));
		$this->set(array("Vlocation"=>$user->getAsObject(array("pos_location"))));
		$this->set(array("Vqualification"=>$user->getAsObject(array("pos_qualification"))));
		$this->set(array("Vjob_catefunc"=>$user->getAsObject(array("pos_job_catefunc"))));
		$this->set(array("Vindustry"=>$user->getAsObject(array("pos_industry"))));
		$this->set(array("Vcom_type"=>$user->getAsObject(array("pos_com_type"))));
		$this->set(array("Vlevel"=>$user->getAsObject(array("pos_level"))));
		$this->set(array("Vlanguage"=>$user->getAsObject(array("pos_language"))));
		$this->set(array("Vgender"=>$user->getAsObject(array("pos_gender"))));
		$this->set(array("Vmarital"=>$user->getAsObject(array("pos_marital")))); */

		//$this->layout ="leditemployer";
		$this->render("edittest");
	}
	public function saveEdit(){
		if(isset($_POST["btnUpdate"])){
			$user = $this->loadModel("Test");
			$user->edit(array(
					"name"=>trim($this->get("txtName")),
					"price"=>trim($this->get("txPrice")),
					"model"=>trim($this->get("txModel")),
					"brand"=>trim($this->get("txtBrand")),array("id"=>$this->get("pid"))));
			$this->index();
		}else{
			//$this->layout ="leditemployer";
			$this->render("edittest");
		}
	}
	public function delete(){
		$user = $this->loadModel("Employer");
		$this->set(array("arrFind"=>$user->delete(array("emp_id"=>$this->get("pid")))));
		$this->set(array("list"=>$user->getList(1,5,"",array("emp_id"))));
		//$this->layout ="ltableemployer";
		$this->render("ltableemployer");
	}
}